/*******************************************************************************
  * @file                   ring_buffer.h
  * @Author:                MQjehovah                 mail:MQjehovah@hotmail.com
  * @version                1.0.0
  * @date                   2016/07/26
  * @brief                  
  ******************************************************************************
  * @attention
*******************************************************************************/
#ifndef _RING_BUFFER_H
#define _RING_BUFFER_H

/* Includes ------------------------------------------------------------------*/
#include "BSP.h"
/* Definition ----------------------------------------------------------------*/
#define RX_BUFFER_SIZE 64

typedef struct _ring_buffer
{
  char buffer[RX_BUFFER_SIZE]; //缓冲区
  u16 head;                    //缓冲区头指针
  u16 tail;                    //缓冲区尾指针
  u32 lenth;                   //缓冲区已使用长度
} ring_buffer;

/* Exported Functions --------------------------------------------------------*/
extern ring_buffer *pSHELL_RX_BUF;

u8 RingBuf_write(ring_buffer *r, unsigned char c);
u8 RingBuf_read(ring_buffer *r, char *c);
void RingBuf_flush(ring_buffer *r);

#endif
/*********************************END OF FILE**********************************/
